<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
		<h1></h1>
		<script type="text/javascript">
			const array = ["星期天","星期一","星期二","星期三","星期四","星期五","星期六"]
			
			function display(){
				let date = new Date()
				let year = date.getFullYear()
				let month = date.getMonth()+1
				let day = date.getDate()
				let h = date.getHours()
				let m = date.getMinutes()
				let s = date.getSeconds()
				//1.if判断星期
				//2.switch
				//3.数组
				let week = array[date.getDay()]
				let str = `${year}-${f(month)}-${f(day)} ${h}:${m}:${s} ${week}`
				document.querySelector("h1").innerHTML = str
			}
			setInterval(display,1000)
			function f(s){
				return s>=10?s:"0"+s
			}
		</script>
	<body>
	</body>
</html>
